import echarts from 'echarts'
import {deep_clone} from '@/common/tool'
// const series_option={
//     type: 'radar',
//     lineStyle: {
//         normal: {
//             width: 1,
//             opacity: 0.5
//         }
//     },
//     symbol: 'none',
//     itemStyle: {
//         color: '#F9713C'
//     },
//     areaStyle: {
//         opacity: 0.1
//     }
// }
const option  = {
    title: {
        text: '',
        left: 'center'
    },
    tooltip: {
        trigger: 'item',
        formatter: '{b} : {c}人 ({d}%)'
    },
    legend: {
        orient: 'vertical',
        right: 120,
        itemGap:30,
        top: 'center',
        data: []
    },
    series: [
        {
            // name: '半径模式',
            type: 'pie',
            radius: [30, 170],
            center: ['30%', '50%'],
            roseType: 'radius',
            label: {
                show: false
            },
            data: []
        }
    ]
};




export default {
    props:['data'],
    render: function (h) {
        return h('div',{
            ref:'charts',
            style:{
                width:'100%',
                height:'400px'
            }
        })
    },
    mounted(){
        const myChart = echarts.init(this.$refs.charts)
        const _option=deep_clone(option)
        _option.title.text=this.data.title
        for (const key in this.data.data) {
            _option.series[0].data.push({
                name:key,
                value:this.data.data[key]
            })
            _option.legend.data.push(key)
        }
        myChart.setOption(_option);
    }
}